<?php // no direct access
defined('_JEXEC') or die('Restricted access'); 

$forgotu = $params->def('forgotu', 1);
$forgotp = $params->def('forgotp', 1);
$login_text = $params->def('login_text', 1);
$register_text = $params->def('register_text', 1);
$message = $params->def('message', 1);

?>
<?php if($type == 'logout') : ?>
<form action="index.php" method="post" name="login" id="form-login">
<?php if ($params->get('greeting')) : ?>
	<div id="s5_login_message">
	<?php if ($params->get('name')) : {
		echo $user->get('name');
	} else : {
		echo $user->get('username');
	} endif; ?>
	,&nbsp;<?php echo $message ?>&nbsp;
	</div>

<?php endif; ?>

	<span id="s5_logout_button">
		<input type="submit" name="Submit" class="button" value="<?php echo JText::_( 'Logout'); ?>" />
	</span>

	<input type="hidden" name="option" value="com_user" />
	<input type="hidden" name="task" value="logout" />
	<input type="hidden" name="return" value="<?php echo $return; ?>" />
</form>
<?php else : ?>
<?php if(JPluginHelper::isEnabled('authentication', 'openid')) :
		$lang->load( 'plg_authentication_openid', JPATH_ADMINISTRATOR );
		$langScript = 	'var JLanguage = {};'.
						' JLanguage.WHAT_IS_OPENID = \''.JText::_( 'WHAT_IS_OPENID' ).'\';'.
						' JLanguage.LOGIN_WITH_OPENID = \''.JText::_( 'LOGIN_WITH_OPENID' ).'\';'.
						' JLanguage.NORMAL_LOGIN = \''.JText::_( 'NORMAL_LOGIN' ).'\';'.
						' var modlogin = 1;';
		$document = &JFactory::getDocument();
		$document->addScriptDeclaration( $langScript );
		JHTML::_('script', 'openid.js');
endif; ?>

<div id="s5_login_icon"></div>
<div id="s5_login_text">
<a style="cursor:pointer" onclick="s5_login_open_close()"><?php echo $login_text ?></a>
</div>

<?php 
$usersConfig = &JComponentHelper::getParams( 'com_users' );
		if ($usersConfig->get('allowUserRegistration')) : ?>
			<div id="s5_register_text">
			<a href="<?php echo JRoute::_( 'index.php?option=com_user&task=register' ); ?>">
				<?php echo $register_text ?></a>
			</div>
		<?php endif; 
		
?>
<div style="clear:both"></div>

<div id="s5_login_wrap" style="display:none; position:absolute">

<form action="<?php echo JRoute::_( 'index.php', true, $params->get('usesecure')); ?>" method="post" name="login" id="form-login" >
	<?php echo $params->get('pretext'); ?>
	<fieldset class="input">
	<p id="form-login-username">
		<label for="modlgn_username"><?php echo JText::_('Username') ?></label><br />
		<input id="modlgn_username" type="text" name="username" class="inputbox" alt="username" style="width:148px" />
	</p>
	<p id="form-login-password">
		<label for="modlgn_passwd"><?php echo JText::_('Password') ?></label><br />
		<input id="modlgn_passwd" type="password" name="passwd" class="inputbox" alt="password" style="width:148px" />
	</p>
	<?php if(JPluginHelper::isEnabled('system', 'remember')) : ?>
	<p id="form-login-remember">
		<label for="modlgn_remember"><?php echo JText::_('Remember me') ?></label>
		<input id="modlgn_remember" type="checkbox" name="remember" class="inputbox" value="yes" alt="Remember Me" />
	</p>
	<?php endif; ?>
	<input type="submit" name="Submit" class="button" value="<?php echo JText::_('LOGIN') ?>" />
	</fieldset>
	<ul>
		<li>
			<a href="<?php echo JRoute::_( 'index.php?option=com_user&view=reset' ); ?>">
			<?php echo $forgotp ?></a>
		</li>
		<li>
			<a href="<?php echo JRoute::_( 'index.php?option=com_user&view=remind' ); ?>">
			<?php echo $forgotu ?></a>
		</li>
	</ul>
	<?php echo $params->get('posttext'); ?>

	<input type="hidden" name="option" value="com_user" />
	<input type="hidden" name="task" value="login" />
	<input type="hidden" name="return" value="<?php echo $return; ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>

</div>


<?php endif; ?>

<script type="text/javascript" language="javascript">

var s5_login_check = 0;

function s5_login_open_close() {
if (s5_login_check == "0") {
document.getElementById("s5_login_wrap").style.display = "block";
document.getElementById("s5_login_text").style.background = "#6A6969";
document.getElementById("s5_login_text").style.paddingRight = "6px";
document.getElementById("s5_login_text").style.borderRight = "solid 1px #393939";
s5_login_check = 1;
}
else {
document.getElementById("s5_login_wrap").style.display = "none";
document.getElementById("s5_login_text").style.background = "none";
document.getElementById("s5_login_text").style.paddingRight = "7px";
document.getElementById("s5_login_text").style.borderRight = "none";
s5_login_check = 0;
}
}

</script>